<?php
/**
 * VIP权益功能测试文件
 */

// 测试VIP权益列表接口
function testVipDetailList() {
    $url = 'http://localhost:8787/admin/vipSolution/vipDetailList';
    $params = [
        'current' => 1,
        'pageSize' => 10
    ];
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query($params));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer your_token_here' // 需要替换为实际的token
    ]);
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    echo "VIP权益列表接口测试:\n";
    echo "HTTP状态码: $httpCode\n";
    echo "响应内容: $response\n\n";
}

// 测试添加VIP权益接口
function testAddVipDetail() {
    $url = 'http://localhost:8787/admin/vipSolution/submitVipDetail';
    $data = [
        'icon' => '/uploads/vip/icon_123456.png', // 上传后的文件路径
        'name' => '测试权益',
        'sub_name' => '测试副标题',
        'description' => '这是一个测试权益'
    ];
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer your_token_here' // 需要替换为实际的token
    ]);
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    echo "添加VIP权益接口测试:\n";
    echo "HTTP状态码: $httpCode\n";
    echo "响应内容: $response\n\n";
}

// 运行测试
echo "开始测试VIP权益功能...\n\n";

// 注意：这些测试需要先登录获取token，并且需要启动后端服务
echo "注意：请确保：\n";
echo "1. 后端服务已启动 (php start.php start)\n";
echo "2. 已登录并获取有效的token\n";
echo "3. 数据库迁移已运行 (php phinx.php migrate)\n\n";

// testVipDetailList();
// testAddVipDetail();

echo "测试完成！\n";
?> 